package com.zhiyou100.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

/**
 * @author yang
 * @className MyArroundAdivce
 * @packageName com.zhiyou100.advice
 * @Description TODO
 * @date 2020-08-19 14:42
 */
public class MyAroundAdvice implements MethodInterceptor {


    /**
     * 目标类执行前后要执行的方法
     *
     * @param invocation
     * @return null 返回 null
     * @throws Throwable
     */
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        final Method method = invocation.getMethod();
        System.out.println(method + " 方法的执行前的通知！！！！！！！！");

        final Object proceed = invocation.proceed();
        System.out.println(method+" 方法的执行后的通知！！！！！！！！");


        return proceed;
    }
}
